/* 
 * File:   StoredTerminal.h
 * Author: cpp
 *
 * Created on May 4, 2010, 3:50 AM
 */

#ifndef _STOREDTERMINAL_H
#define	_STOREDTERMINAL_H
#include "Terminal.h"

class StoredTerminal : public Terminal {
public:
    StoredTerminal();
    StoredTerminal(const StoredTerminal& orig);
    virtual ~StoredTerminal();
    void setId(const std::string& id);
    string getSID();
    string getMasked();
    void setMasked(string m);


private:
    string masked;
};

StoredTerminal::StoredTerminal() {
}

StoredTerminal::StoredTerminal(const StoredTerminal& orig) {
    id = orig.id;
    value = orig.value;
}

StoredTerminal::~StoredTerminal() {
}

void StoredTerminal::setId(const std::string& id) {
    if ((id.substr(0, 3) == "(S:") && (id[id.size() - 1] == ')'))//and
    {
        this->id = id;
    }
}

string StoredTerminal::getSID() {
    //Converts (L:"ABC") in 'A' 'B' 'C' for parser
    //Remark: parsed result is converted to  (LT:'A''B')
    stringstream printstream;
    string sid;

    sid = this->getId();
    if (sid == "(S:&CLEAR)") {
        printstream << "{ clearDRT();}";

    } else {

        if (sid == "(S:&APPEND)") {
            printstream << "{ copyContainer();}";
        } else {
            printstream << "{ storeDRT(\"" << sid;
            printstream << "\");} ";
        }

    }



    return printstream.str();
}

string StoredTerminal::getMasked(){
    return masked;
}

void StoredTerminal::setMasked(string m){
    masked = m;
}
#endif	/* _STOREDTERMINAL_H */

